<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title></title>
</head>
<body>
<!--弹窗：经费暂停-->
<div th:fragment="moneyinfoSuspendedList" class="modal inmodal fade" id="moneyinfoSuspendedList_Modal"
     tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span></button>
                <h4 class="modal-title" id="moneyinfoSuspendedList_modalTitle">经费暂停列表</h4>
                <p id="moneyinfoSuspendedList_modalDesc" class="font-bold text-danger"></p>
            </div>
            <div class="modal-body">
                <table id="moneyinfoSuspendedList_table" class="table table-striped"></table>
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $(function () {
            moneyinfoSuspendedListObj.myTable = $('#moneyinfoSuspendedList_table').bootstrapTable({
                toolbar: "moneyinfo_table_toolbar",
                exportDataType: "",
                exportTypes: ['excel'],
                exportOptions: {
                    fileName: function () {
                        return '预算导出'
                    }
                },
                formatNoMatches: function () {  //没有匹配的结果
                    return '暂无数据';
                },
                method: 'post',
                columns: [{
                    title: '#',
                    align: 'center',
                    width: 50,
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                }, {
                    title: '经费类型',
                    field: 'moneyTypeName'
                }, {
                    title: '预算项目',
                    field: 'projectName',
                    formatter: function (value, row, index) {
                        return value + `(${row.projectCode})`;
                    }
                }, {
                    title: '经济分类',
                    field: 'cateName',
                    formatter: function (value, row, index) {
                        return value + `(${row.cateCode})`;
                    }
                }, {
                    title: '暂停金额',
                    field: 'totalMoney',
                    formatter: function (value, row, index) {
                        return $.moneyFormat(value);
                    }
                }, {
                    title: '操作',
                    width: 80,
                    events: {
                        'click .trash': function (e, value, row, index) {
                            moneyinfoSuspendedListObj.deleteHandler(row.id)
                        }
                    },
                    formatter: function (value, row, index) {
                        var opers = [];
                        opers.push(`<a class="trash btn btn-white btn-bitbucket text-success" data-toggle="tooltip" data-placement="top" title="删除">
                                    <i class="fa fa-trash"></i>
                                </a>`)
                        return opers.join('');
                    }
                }],
                responseHandler: function (res) {
                    return res.list;
                }
            });
        })
        var moneyinfoSuspendedListObj = new Object({
            myTable: undefined,
            myModal: $('#moneyinfoSuspendedList_Modal'),
            init() {
                this.myTable.bootstrapTable('refresh',{
                    url: `/money/cur/moneyinfo/querySuspended/${moneyinfoObj.selectRow.id}`
                })
                this.toggleModal(true)
            },
            toggleModal: function (show) {
                this.myModal.modal(show ? 'show' : 'hide');
            },
            deleteHandler(id) {
                let _self = this;
                let ids = id ? [id] : _self.myTable.bootstrapTable('getSelections');
                $.mySwalConfirm("将删除暂停，确认吗？", function () {
                    $.myDelete({
                        url: `/money/cur/moneyinfo`,
                        dataType: 'json',
                        data: ids,
                        success: function (data) {
                            if (data && data.code === 0) {
                                toastr.success(data.msg, '操作提示')
                                _self.myTable.bootstrapTable('refresh')
                                moneyinfoObj.refreshTable()
                            } else {
                                toastr.error(data.msg, '操作失败')
                            }
                        }
                    })
                });
            }
        })
    </script>

</div>
</body>
</html>